<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuimini/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-tab layui-tab-brief" lay-filter="tabFilter" style="background-color: #FFFFFF">
            <ul class="layui-tab-title">
                <li lay-id="1" class="layui-this">个人资料</li>
                <li lay-id="2">余额补贴</li>
                <li lay-id="3">联盟设置</li>
                <li lay-id="4">订单数据</li>
                <li lay-id="5">提成补贴</li>
                <li lay-id="6">签到数据</li>
                <li lay-id="7">购物标签</li>
            </ul>
            <div class="layui-tab-content">
                <!-- 个人资料 -->
                <div class="layui-tab-item layui-show">
                    <form class="layui-form layui-form-pane" lay-filter="grzl">
                        <div class="layui-form-item">
                            <label class="layui-form-label">所属机器人</label>
                            <div class="layui-input-inline" readonly>
                                <input type="text" class="layui-input robot-name" name="robot_id" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">微信号</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="openid" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">上级ID</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="father_id" readonly>
                            </div>
                        </div>
                        <!--
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户状态</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="user_type" readonly>
                            </div>
                        </div> -->
                        <div class="layui-form-item">
                            <label class="layui-form-label">支付宝名称</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="alipay_name">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">支付宝账号</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="alipay_user">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">分组名称</label>
                            <div class="layui-input-inline" readonly>
                                <input type="text" class="layui-input" name="group_name" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">备注名称</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="wx_note">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">来源</label>
                            <div class="layui-input-inline" readonly>
                                <input type="text" class="layui-input" name="user_source" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户创建时间</label>
                            <div class="layui-input-inline" readonly>
                                <input type="text" class="layui-input" name="create_time" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn btn-grzl" type="button" style="margin-top: 10px">确认修改</button>
                        </div>
                    </form>
                </div>
                <!-- 余额补贴 -->
                <div class="layui-tab-item">
                    <form class="layui-form layui-form-pane" lay-filter="yebt">
                        <div class="layui-form-item">
                            <label class="layui-form-label">可提现</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="effec_money">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">已提现</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="take_money" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">邀请奖励</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="invite_fee" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">签到奖励</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="signin_fee" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">积分变动时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="update_money_time" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn btn-yebt" type="button" style="margin-top: 10px">确认修改</button>
                        </div>
                    </form>
                </div>
                <!-- 联盟资料 -->
                <div class="layui-tab-item">
                    <form class="layui-form layui-form-pane" lay-filter="cps">
                        <div class="layui-form-item">
                            <label class="layui-form-label">定向佣金比例</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="fixed_rate">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">代理佣金比例</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="exclusive_rate">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">上级提成比例</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="father_rate">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">订单尾号</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="tb_order_sixbit">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">代理(淘宝pid)</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="tb_pid">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">代理(拼多多pid)</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="pdd_pid">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">代理(京东pid)</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="jd_pid">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn btn-cps" type="button" style="margin-top: 10px">确认修改</button>
                        </div>
                    </form>
                </div>
                <!-- 订单数据 -->
                <div class="layui-tab-item">
                    <form class="layui-form layui-form-pane" lay-filter="order">
                        <div class="layui-form-item">
                            <label class="layui-form-label">待收货补贴</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="pay_order_fee">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">已结算补贴</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="pub_order_fee">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">冻结中补贴</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="for_order_fee">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">已失效补贴</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="inv_order_fee">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">待收货笔数</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="pay_order_num">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">已结算笔数</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="pub_order_num">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">冻结中笔数</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="for_order_num">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">已失效笔数</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="inv_order_num">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">最后下单时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="update_order_time" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn btn-order" type="button" style="margin-top: 10px">确认修改</button>
                        </div>
                    </form>
                </div>
                <!-- 提成补贴 -->
                <div class="layui-tab-item">
                    <form class="layui-form layui-form-pane" lay-filter="comm">
                        <div class="layui-form-item">
                            <label class="layui-form-label">提成待收货补贴</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="pay_order_comm">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">提成已结算补贴</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="pub_order_comm">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">提成冻结中补贴</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="for_order_comm">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">提成已失效补贴</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="inv_order_comm">
                            </div>
                            <i class="layui-icon layui-icon-">可修改</i>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn btn-comm" type="button" style="margin-top: 10px">确认修改</button>
                        </div>
                    </form>
                </div>
                <!-- 签到数据 -->
                <div class="layui-tab-item">
                    <form class="layui-form layui-form-pane" lay-filter="signin">
                        <div class="layui-form-item">
                            <label class="layui-form-label">签到奖励</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="signin_fee" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">累计签到</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="signin_count" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">连续签到</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="signin_always_count" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">最后签到时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="signin_time" readonly>
                            </div>
                        </div>
                    </form>
                </div>
                <!-- 购物标签 -->
                <div class="layui-tab-item">
                    <form class="layui-form layui-form-pane" lay-filter="label">
                        <div class="layui-form-item layui-form-text">
                            <textarea class="layui-textarea" name="label" style="height: 300px"></textarea>
                        </div>
                    </form>
                </div>
            </div>
        </div>

    </div>
</div>

<script src="/static/layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['layer', 'form', 'element', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            element = layui.element,
            $ = layui.jquery,
            wximg = getQueryVariable('id'),
            wxId = getQueryVariable('id');

        // $('.wx-img img').attr('src',wximg);
        // $('.layui-form-label').css('width', '138px')
        // $('.layui-input-inline').css('width', '470px')
        // $('.layui-form-item').css('margin-bottom', '2px')

        //获取数据
        $.ajax({
            url: "{:url('data/getMemberInfo')}",
            type: 'GET',
            dataType: 'json',
            data: {id: wxId},
            beforeSend: function () {
                loadIndex = layer.load(0, {
                    shade: [0.1, '#fff']
                });
            },
            complete: function () {
                layer.close(loadIndex);
            },
            success: function (d) {
                // $('.wx-id').html('微信ID：'+d.data.wx_id);
                // $('.wx-name').html('名称：'+ d.data.wx_name);
                form.val('grzl', {
                    robot_id: d.data.robot_id,
                    father_id: d.data.father_id,
                    openid: d.data.openid,
                    user_type: d.data.user_type == 1 ? '正常' : '黑名单',
                    user_source: d.data.user_source,
                    alipay_name: d.data.alipay_name,
                    alipay_user: d.data.alipay_user,
                    group_name: d.data.group_name,
                    wx_note: d.data.wx_note,
                    create_time: d.data.create_time,
                })
                form.val('yebt', {
                    effec_money: d.data.effec_money,
                    take_money: d.data.take_money,
                    invite_fee: d.data.invite_fee,
                    signin_fee: d.data.signin_fee,
                    update_money_time: d.data.update_money_time,
                })
                form.val('cps', {
                    fixed_rate: d.data.fixed_rate,
                    exclusive_rate: d.data.exclusive_rate,
                    tb_order_sixbit: d.data.tb_order_sixbit,
                    tb_pid: d.data.tb_pid,
                    pdd_pid: d.data.pdd_pid,
                    jd_pid: d.data.jd_pid,
                    father_rate: d.data.father_rate
                })
                form.val('order', {
                    pay_order_fee: d.data.pay_order_fee,
                    pub_order_fee: d.data.pub_order_fee,
                    inv_order_fee: d.data.inv_order_fee,
                    for_order_fee: d.data.for_order_fee,
                    pay_order_num: d.data.pay_order_num,
                    pub_order_num: d.data.pub_order_num,
                    inv_order_num: d.data.inv_order_num,
                    for_order_num: d.data.for_order_num,
                    update_order_time: d.data.update_order_time
                })
                form.val('comm', {
                    pay_order_comm: d.data.pay_order_comm,
                    pub_order_comm: d.data.pub_order_comm,
                    inv_order_comm: d.data.inv_order_comm,
                    for_order_comm: d.data.for_order_comm,
                })
                form.val('signin', {
                    signin_fee: d.data.signin_fee,
                    signin_time: d.data.signin_time,
                    signin_count: d.data.signin_count,
                    signin_always_count: d.data.signin_always_count,
                })
                form.val('label', {
                    label: d.data.label,
                })
                form.render();
            },
            error: function (d) {
                console.log('获取配置失败');
            }
        })
        //修改个人资料
        $('.btn-grzl').click(function (d) {
            var data = JSON.stringify(form.val('grzl'));
            updMemberInfo(1, data);
        })
        //修改余额补贴
        $('.btn-yebt').click(function (d) {
            var data = JSON.stringify(form.val('yebt'));
            updMemberInfo(2, data);
        })
        //修改订单数据
        $('.btn-order').click(function (d) {
            var data = JSON.stringify(form.val('order'));
            //layer.alert(data);return;
            updMemberInfo(4, data);
        })
        //修改联盟资料
        $('.btn-cps').click(function (d) {
            var formData = form.val('cps');
            if (formData.tb_order_sixbit.length >= 1 && formData.tb_order_sixbit.length != 6) {
                layer.alert('订单尾号必须是长度6位', {icon: 2, title: '温馨提示'});
                return;
            }
            if (formData.tb_pid.length >= 1 && formData.tb_pid.split('_').length != 4) {
                layer.alert('淘宝pid格式不对', {icon: 2, title: '温馨提示'});
                return;
            }
            if (formData.pdd_pid.length >= 1 && formData.pdd_pid.split('_').length != 2) {
                layer.alert('拼多多pid格式不对', {icon: 2, title: '温馨提示'});
                return;
            }
            var data = JSON.stringify(formData);
            updMemberInfo(3, data);
        })
        //修改提成数据
        $('.btn-comm').click(function (d) {
            var data = JSON.stringify(form.val('comm'));
            //layer.alert(data);return;
            updMemberInfo(5, data);
        })

//获得浏览器地址get参数
        function getQueryVariable(variable) {
            var query = decodeURIComponent(window.location.search.substring(1));
            var vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split("=");
                if (pair[0] == variable) {
                    return unescape(pair[1]);
                }
            }
            return (false);
        }

        //保存修改数据
        function updMemberInfo(type, data) {
            var wxName = $('.wx-name').html(), robotName = $('.robot-name').val();
            $.ajax({
                url: "{:url('manage')}",
                type: 'POST',
                dataType: 'json',
                data: {
                    typeName: 'updMemberInfo',
                    type: type,
                    wxId: wxId,
                    wxName: wxName,
                    robotName: robotName,
                    data: data
                },
                beforeSend: function () {
                    loadIndex = layer.load(0, {
                        shade: [0.1, '#fff']
                    });
                },
                complete: function () {
                    layer.close(loadIndex);
                },
                success: function (d) {
                    console.log(d);
                    if (d.code == 1) {
                        layer.msg('修改成功');
                    } else {
                        layer.alert(d.error, {icon: 2, title: '温馨提示'});
                    }
                },
                error: function (d) {
                    console.log(d);
                    console.log('获取配置33失败');
                }
            });
        }
    })
</script>

</body>
</html>